package com.youfang.sixthmedia.message;

import java.util.LinkedList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.youfang.sixthmedia.message.model.Advertisment;
import com.youfang.sixthmedia.net.Response;

/**
 * 获取新楼房列表请求
 * 
 * @author Administrator
 * 
 */
public class AdvertisementResponse extends Response {

	private List<Advertisment> ads = new LinkedList<Advertisment>();
	private String batchID;

	@Override
	protected void decodeBody(JSONObject bodyJSON) throws Exception {

		JSONArray arr = bodyJSON.getJSONArray("data");

		batchID = String.valueOf(System.nanoTime());
		for (int i = 0; i < arr.length(); i++) {
			JSONObject o = arr.getJSONObject(i);
			Advertisment ad = new Advertisment();
			ad.batchID = batchID;// 标明是同一批次的广告
			ad.advertisementid = o.getString("advertisementid");
			ad.advertisementname = o.getString("advertisementname");
			ad.advertisementurl = o.getString("advertisementurl");
			ad.advertisementimg = o.getString("advertisementimg");
			ad.isenable = o.getString("isenable");
			this.ads.add(ad);

		}

	}

	public String getBatchID() {
		return batchID;
	}

	public void setBatchID(String batchID) {
		this.batchID = batchID;
	}

	public List<Advertisment> getAds() {
		return ads;
	}

	public void setAds(List<Advertisment> ads) {
		this.ads = ads;
	}

}
